import { createRouter, createWebHashHistory } from 'vue-router'
import beforeRoute from './plugin/beforeRoute'
import route from './pageRoute';
// import Login from '@/views/login/Login.vue';

export const constantRoutes = [
  {
    path: '',
    redirect: "/home",
    hidden: true
  },
  {
    path: '/login',
    name: "登录",
    // component: Login,
    component: () => import('@/views/login/Login.vue'),
    hidden: true
  },
  //消除页面报警告
  // {
  //   path: "/:pathMatch(.*)*",
  //   name: "notMatch",
  //   hidden: true,
  //   component: () => import("@/views/notFind/404.vue"),
  // },
  {
    path: '/home',
    redirect: '/welcome',
    name: "首页",
    component: () => import('@/components/home/Home.vue'),
    children: [{
      path: '/welcome',
      name: "欢迎",
      component: () => import('@/views/welcome/welcome.vue'),
      hidden: true
    }]
  },
  {
    path: "/:catchAll(.*)",
    name: "NotFound",
    component: () => import("@/views/notFind/404.vue"),
    hidden: true,
    meta: { title: "404" },
  },
  // 当什么都没有匹配到的时候，重定向页面到 404 页面
  // {
  //   path: '/:catchAll(.*)',
  //   hidden: true,
  //   component: () => import('@/views/error/404.vue')//这个是我自己的路径
  // }
]


const router = createRouter({
  history: createWebHashHistory(),
  scrollBehavior: () => ({ top: 0 }),
  routes: constantRoutes
})

beforeRoute(router, constantRoutes);

export default router
